package vesion2.object;

import vesion2.object.special.Topology;

import java.awt.*;

public class Circle extends GameObject{
    protected Point center;
    protected int radius;

    /**
     *
     * @param center 圆心
     * @param radius 半径
     */
    public Circle(Point center,int radius){
        this(center,radius,null,null);
    }

    public Circle(Point center,int radius,Color backColor,Image image){
        super(backColor,image);
        this.center=center;
        this.radius=radius;
    }

    public Point getCenter() {
        return center;
    }

    public void setCenter(Point center) {
        this.center = center;
    }

    public int getRadius() {
        return radius;
    }

    public void setRadius(int radius) {
        this.radius = radius;
    }

    @Override
    public void draw(Graphics g) {
        g.setColor(backColor);
        g.fillOval(center.getX()-radius,center.getY()-radius,2*radius,2*radius);
    }

    @Override
    public boolean isIntersect(GameObject object) {
        return Topology.isIntersect(this,object);
    }
}
